package com.yuan.send.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author 小源同学
 * @Date 2022 02 05 22 12
 * @Describe RabbitMQ的配置类
 **/
@Configuration
public class RabbitMQConfig {

    //声明队列
    @Bean
    public Queue queue() {
        return new Queue("amqp_queue");
    }

    //声明交换机
    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("amqp_exchange");
    }

    //绑定交换机和队列
    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(topicExchange()).with("*.amqp.#");
    }
}
